<template>
    <div>
      <span v-if="has_error">操作失败</span>
      <span v-else>正在登录..</span>
    </div>
</template>

<script>
export default {
  data(){
    return{
      has_error: false
    }
  },
  async asyncData({ $axios, req }) {
    return {"info": req.query}    
  },
  mounted(){
    if (this.info.action === undefined){
        this.has_error = true
    }

    if (this.info.name == ''){
        this.has_error = true
    }

    if (this.info.action == "bind_mobile" && (this.info.wid == '' || this.info.uid == -1 )){
        this.has_error = true
    }

    if( !this.has_error ){
      var data = {
        "action":this.info.action,"name":this.info.name,"avatar":this.info.avatar,"userid":this.info.uid
      }
      
      if(this.info.action=="bind_mobile"){
        data.wid = this.info.wid
      }
        
      parent.postMessage(data, '*');
    }
  }

}
</script>